package com.xinjiang.electricpower.controller;

/**
 * @author feizhao
 * @date 2022/12/6
 * @apiNote 供电所控制层类
 */

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.xinjiang.electricpower.domain.DTO.SysOrgDTO;
import com.xinjiang.electricpower.domain.vo.OrgConfigVO;
import com.xinjiang.electricpower.service.ISysOrgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/xinjiang-power-supply-station/geo-app-org-config/")
@Api(value = "地图应用-供电所配置", tags = "地图应用-供电所配置")
@Validated//有此注解，才会校验游离的参数
@Slf4j
@RequiredArgsConstructor
public class SysOrgController {

    private final ISysOrgService sysOrgService;


    /**
     * @param sysOrgDTO 供电所sysOrgDTO类
     * @param page                     分页对象
     * @return R<IPage <WorkOrderMonitorVO>> 查询供电所列表
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询供电所列表", notes = "查询供电所列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "workOrderEarlyWarningDTO", value = "工单监控DTO类", paramType = "query", dataType = "WorkOrderEarlyWarningDTO", dataTypeClass = com.xinjiang.electricpower.domain.DTO.WorkOrderEarlyWarningDTO.class),
            @ApiImplicitParam(name = "page", value = "分页对象", paramType = "query", dataType = "PageDTO<XjOrderGeneralVO>", dataTypeClass = com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO.class)
    })
    public R<IPage<OrgConfigVO>> getXjOrderGeneralProcess(SysOrgDTO sysOrgDTO, Page<OrgConfigVO> page) {
        IPage<OrgConfigVO> pages = sysOrgService.getSysOrgList(page,sysOrgDTO);
        return R.ok(pages, "查询成功");
    }
    /**
     * @return R<Long> 返回结果
     * @description 制单/更新派工单
     */
    @PutMapping("/update")
    @Log(title = "修改经纬度", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "修改经纬度", notes = "修改经纬度")
    public R<Object> updateOrgNoInfo(@RequestBody SysOrgDTO sysOrgDTO) {
        boolean flag = sysOrgService.updateOrgNoInfoById(sysOrgDTO);
        if(flag){
            return R.ok();
        }
        return R.fail("操作失败");
    }
}
